/*
 * @Author: liangliang
 * @Date: 2023-07-25 14:03:48
 * @LastEditors: yusha
 * @LastEditTime: 2023-08-25 14:28:04
 * @Description: 修改后台接口请求环境
 */
import qs from 'query-string';

const getQueryEnv = () => {
    const query = qs.parse(window.location.search) as { _env?: string; };
    return query?._env;
};

// 1. 可以在 url 上配置
// 2. 可以在 代码中 动态改动
// 3. 根据域名处理
export const serviceConfig = (() => {
    return {
        baseURL: (() => {
            // const queryEnv = getQueryEnv();
            // if(queryEnv){
            //     return getRquestBaseUrlByEnv(queryEnv);
            // }
            const devUrl = 'http://localhost:8804';
            // const devUrl = 'https://titancenter-api.sniffgroup.com';
            // const devUrl = 'https://gateway-prod.theckb.com';
            // const devUrl = 'https://master-gateway.theckb.com';
            const isOnline = window.location.host.includes('192.168.201.128') || window.location.host.includes('titancenter');

            // 如果是线上环境
            if (isOnline) return 'https://titancenter-api.sniffgroup.com';
            return devUrl;
        })(),
    };
})();
